<template>
	<view class="cart">
		<view class="add">
			<view class="ey same">
				<text >车牌号</text>
			</view>
			
			<up-input
			    placeholder="请输入车牌号"
			    border="surround"
			    v-model="putvalue"
			  ></up-input>
			 
			 <view class="pcarttype same">
				 <view class="ey same">
			 	<text >车辆类型</text>
				</view>
				
			 	<u-radio-group 
			 	    v-model="typevalue"
			 	    placement="row">
			 	<u-radio 
			 		:customStyle="{marginBottom: '8px'}"
			 		v-for="(item, index) in radiolist"
			 		:key="index"
			 		:label="item.name"
			 		:name="item.name"
			 		></u-radio>
			 	</u-radio-group>
			 	
			 </view> 
			  
			  <view class="same">
			  	 <up-button type="primary" text="添加" @click="addcardeta"></up-button>
			  </view>
			  
			  <view class="same">
			  <up-button type="primary" 
			  :plain="true" 
			  :hairline="true"
			  text="查询我的车辆"
			  @click='getmycart'
			  
			  ></up-button>
			 </view>
			 
			<view class="same">
				<up-button type="success" :plain="true" text="我的车辆里程" @click='gotoconsumption'></up-button>
			</view>
			
			<view class="same">
				<up-button type="warning" :plain="true" text="申请挪车" @click='gotomove'></up-button>
			</view>
			
			<view class="same">
				<up-button type="error" :plain="true" text="查询挪车记录" @click='gohismove'></up-button>
			</view>
		</view>
	</view>
</template>

<script setup>
import { reactive, ref } from 'vue';
import {addcar} from '../../../api/parkApi.js'
	
	const putvalue= ref() //车牌号
	const typevalue=ref() //车类型
	
	const radiolist=reactive([
		{
			name: '新能源车',
			disabled: false,
		
		},
		{
			name: '汽油车',
			disabled: false,
		
		},
		
	])
	
	//点击查询挪车历史
	const gohismove=()=>{
		uni.navigateTo({
			url:"/pages/park/cart/movecart/hismove/hismove"
		})
	}
	
	//点击申请挪车
	const gotomove=()=>{
		uni.navigateTo({
			url:"/pages/park/cart/movecart/movecart"
		})
	}
	
	//点击我的车辆里程
	const gotoconsumption=()=>{
		uni.navigateTo({
			url:'/pages/park/cart/consumption/consumption'
		})
	}
	
	//点击查询我的车辆
	const getmycart=()=>{
		uni.navigateTo({
			url:'/pages/park/cart/mycart/mycart'
		})
	}
	
	//点击添加车辆
	const addcardeta=async()=>{
	
          	if(putvalue.value==undefined || typevalue.value==undefined){
	      		uni.showToast({
				title:'内容不能为空',
				icon:'error'
			})
			return;
		}
	
     	let res = await addcar({
			header:{
				'Authorization':uni.getStorageSync('token')
			},
			data:{
				plateNo:putvalue.value,
				type:typevalue.value
			}
		})
		if(res.code==200){
			uni.showToast({
				title:'添加成功'
			})
		}else{
			//静态数据
			uni.showToast({
				title:'添加成功'
			})
			
		}
	}
	
</script>

<style lang="scss">
.cart{
	padding: 6px 10px;
	.ey{
		padding: 0px 4px ;
		font-size: 16px;
		font-weight: 700;
		
	}
	.same{
		margin: 10px 0px;
	}
	::v-deep .u-radio-group{
		display: flex;
		justify-content: space-evenly;
	}
}
</style>
